<div class="row">
  <div class="col-md-8">
    <div class="card">
      <div class="card-header">
        <h3 class="card-title">Check <%= @check.name %></h3>
        <div class="card-options">
          <%= link_to 'JSON',
            check_path(@check, format: :json), class: 'btn btn-success btn-sm'%>
        </div>
      </div>
      <div class="card-body">
        <p>
          <%= link_to '<i class="fe fe-edit"></i> Edit'.html_safe, edit_check_path(@check), class: 'btn btn-outline-info btn-sm' %>
          <div id="notice"><%= notice %></div>
        </p>

        <p>
          <strong>Active:</strong>
          <span class="<%= class_for_active(@check.active) %>"><%= @check.active %></span>
        </p>

        <p>
          <strong>Cron:</strong>
          <code><%= @check.cron %></code>
          <%= link_to '<i class="fe fe-external-link"></i> crontab.guru'.html_safe, "https://crontab.guru/##{@check.cron.split(' ').join('_')}", target: :_blank %>
        </p>

        <p>
          <strong>URL:</strong>
          <%= link_to @check.url, @check.url %>
        </p>

        <p>
          <strong>Status:</strong>
          <span class="text-<%= class_for_status(@check.status) %>">
            <strong><%= @check.status %></strong>
          </span>
        </p>

        <p>
          <strong>Next contact:</strong>
          <span><%= @check.next_contact_at %></span>
        </p>

        <p>
          <strong>Last contact:</strong>
          <span><%= @check.last_contact_at %></span>
        </p>

        <% if URI.parse(@check.url).scheme == 'https' && @check.tls_expires_at? %>
        <p>
          <strong>TLS expires at:</strong>
          <span class="<%= class_for_tls_expires_in_days(@check.tls_expires_in_days) %>">
            <%= @check.tls_expires_at %> (in <%= @check.tls_expires_in_days %> days)
          </span>
        </p>
        <% end %>

        <p>
          <strong>Status changes: <%= @check.status_changes.count %></strong>
          <ul>
          <% @check.status_changes.order(created_at: :desc).each do |status_change| %>
            <li><%= status_change.created_at %>
            <% if status_change.status.to_i.between?(100, 599) %>
              <span class="badge badge-<%= class_for_status(status_change.status) %>"><%= status_change.status %></span>
            <% else %>
              <span class="small text-danger"><%= status_change.status %></span>
            <% end %>
            </li>
          <% end %>
          </ul>
        </p>

        <p>
          <strong>Debug:</strong> <%= link_to @check.job, check_job_path(@check) %>
        </p>

        <p>
          <%= button_to @check, class: "btn btn-outline-danger btn-sm", method: :delete do %>
            <i class="fe fe-trash"></i> Delete
          <% end %>
        </p>
      </div>
    </div>
  </div>
</div>
